//
//  MNDTransactionRecordHeaderView.m
//  minidai
//
//  Created by Steven.Yung on 2017/5/18.
//  Copyright © 2017年 迷你金服. All rights reserved.
//

#import "MNDTransactionRecordHeaderView.h"
#import "UIButton+JKImagePosition.h"

@interface MNDTransactionRecordHeaderView ()

@property (strong, nonatomic) UIButton *headerButton;

@end

@implementation MNDTransactionRecordHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithReuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.contentView.backgroundColor = kColorBackground;
        [self makeContentsConstraints];
        
    }
    return self;
}

- (void)makeContentsConstraints {
    [self.monthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.contentView).offset(15.0);
        make.centerY.equalTo(self.contentView);
    }];
    
    [self.headerButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(self.contentView).offset(-15.0);
        make.centerY.equalTo(self.contentView);
        make.height.equalTo(self.contentView);
    }];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)headerDidClikAction:(UIButton *)sender {
    if (self.headerDidClickBlock) {
        self.headerDidClickBlock();
    }
}

- (UIButton *)headerButton {
    if (!_headerButton) {
        _headerButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_headerButton addTarget:self action:@selector(headerDidClikAction:) forControlEvents:UIControlEventTouchUpInside];
        [_headerButton setTitle:@"" forState:UIControlStateNormal];
        _headerButton.titleLabel.font = [UIFont systemFontOfSize:13.0];
        [_headerButton setTitleColor:kColorGray forState:UIControlStateNormal];
//        [_headerButton setImage:[UIImage imageNamed:@"deposit_progress"] forState:UIControlStateNormal];
//        [_headerButton jk_setImagePosition:LXMImagePositionRight spacing:3.0];
        [self.contentView addSubview:_headerButton];
    }
    
    return _headerButton;
}

- (UILabel *)monthLabel {
    if (!_monthLabel) {
        _monthLabel = [self labelWithDefaultText:@"2017年本月" textColor:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0] fontSize:13.0];
        [self.contentView addSubview:_monthLabel];
    }
    
    return _monthLabel;
}
- (UILabel *)labelWithDefaultText:(NSString *)text textColor:(UIColor *)color fontSize:(CGFloat)size {
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.text = text;
    label.textColor = color;
    label.font = [UIFont fontWithName:@"PingFangSC-Regular" size:size];
    
    return label;
}

@end
